#ifndef CPP_IMAGEVIEW_H
#define CPP_IMAGEVIEW_H

#include <widget/View.h>

class Bitmap;

//@brief 图片
//@author cvte
//@description 图片显示控件
class ImageView : public View {
   public:
    enum class ScaleType {
        CENTER,
        CENTER_CROP,
        CENTER_INSIDE,
        FIT_CENTER,
        FIT_END,
        FIT_START,
        FIT_XY,
        MATRIX
    };
    ImageView();
    ~ImageView();

    void setScaleType(ScaleType scaleType);
    /**
         *是否选中
         */
    void setSelected(bool selected);
    void setEnabled(bool enabled);
    void setImageLevel(int level);
    /**
         *设置位图资源
         */
    void setImageBitmap(Bitmap& src);
    void setImageResource(int resId);
    void setMaxWidth(int maxWidth);
    void setMaxHeight(int maxHeight);
    void setAdjustViewBounds(bool adjustViewBounds);
    void setImageAlpha(int alpha);

    ScaleType getScaleType();
    bool getAdjustViewBounds();
    int getImageAlpha();

   protected:
    void onAttachedToWindow();
    void onDetachedFromWindow();
    void onDraw(Canvas& canvas);

   private:
    Bitmap* mSource = nullptr;
};

#endif /* CPP_IMAGEVIEW_H */